package com.pactera.elasticsearch.utils;

import com.pactera.elasticsearch.exception.ElasticException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.lang.Nullable;

public class Assert {

    private Assert() {
    }

    public static void isFalse(boolean expression, String message) {
        if (expression) {
            throw new ElasticException(message);
        }
    }

    public static void isTrue(boolean expression, String message) {
        isFalse(!expression, message);
    }

    public static void isNotNull(@Nullable Object object, String message) {
        isFalse(object == null, message);
    }

    public static void isNull(@Nullable Object object, String message) {
        isFalse(object != null, message);
    }

    public static void isNotBlank(@Nullable String text, String message) {
        isFalse(StringUtils.isBlank(text), message);
    }

    public static void isBlank(@Nullable String text, String message) {
        isFalse(StringUtils.isNotBlank(text), message);
    }
}
